package bookez.model.service.impl;

import java.util.List;

import bookez.model.businessobject.TripSchedule;
import bookez.model.dao.TripScheduleDao;
import bookez.model.exception.BusinessLogicLayerException;
import bookez.model.exception.DataAccessLayerException;
import bookez.model.service.GenericService;
import bookez.model.service.TripScheduleService;

public class TripScheduleServiceImpl extends GenericService<TripScheduleDao> implements TripScheduleService{

	@Override
	public List<TripSchedule> getAllTripSchedule()
			throws BusinessLogicLayerException {
		// TODO Auto-generated method stub
		List<TripSchedule> result = null;
		
		try {
			result = getDao().findAll();
		}//end try
		
		catch ( DataAccessLayerException dalEx ) {
			throw new BusinessLogicLayerException( dalEx );
		}//end catch
		
		return result;
	}//end method getAllTripSchedule

	@Override
	public boolean createTripSchedule(TripSchedule schedule)
			throws BusinessLogicLayerException {		
		try {
			getDao().create( schedule );
			return true;
		}//end try
		
		catch( DataAccessLayerException dalex ) {
			throw new BusinessLogicLayerException( dalex );
		}//end catch		
	}//end method createTripSchedule

	@Override
	public boolean saveTripSchedule(TripSchedule schedule)
			throws BusinessLogicLayerException {		
		try {
			getDao().update( schedule );
			return true;
		}//end try
		
		catch ( DataAccessLayerException dalex ) {
			throw new BusinessLogicLayerException( dalex );
		}//end catch
	}//end method saveTripSchedule

	@Override
	public TripSchedule getByTripCode(String tripCode)
			throws BusinessLogicLayerException {
		// TODO Auto-generated method stub
		
		try {
			TripSchedule token = getDao().findByTripCode( tripCode );
			return token;
		}//end try
		
		catch ( DataAccessLayerException dalex ) {
			throw new BusinessLogicLayerException( dalex );
		}//end catch
	}//endm method getByTripCode

}//end class TripScheduleServiceImpl
